package com.lgx.right.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;

/**
 * 
 * 
 * @author acer
 *
 */
@Entity
@Table(name="TS_ORGANIZATION")
public class Organization implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TS_ORGANIZATION_ID)
	@TableGenerator(
			name = IdGenerator.TS_ORGANIZATION_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TS_ORGANIZATION_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	/**
	 * 商家、机构
	 */
	private String name;//商家名称
	
	/**
	 * 类型：1联盟商家、2推广站、3推广中心、4运营中心/分子公司、5总公司
	 */
	private String type;//商家类型
	
	private String address;//商家地址
	
	/**
	 * 省
	 */
	private String province;
	
	/**
	 * 市
	 */
	private String city;
	
	/**
	 * 县、区
	 */
	private String county;
	
	private String tel;//商家电话
	
	private String star;//商家评定星级
	
	private String beginTime;//商家运营开始时间
	
	private String endTime;//商家运营结束时间
	
	private String isSend;//是否送货上门
	
	@ManyToOne
	@JoinColumn(name="legal_id")
	private User legal;//商家法人代表、负债人
	
	private String code;//商家工商注册编号
	
	@ManyToOne
	@JoinColumn(name="parent")
	private Organization parent;//所属机构编号
	
	private double sscore;//剩余积分数量
	
	private double ascore;//返利钱包
	
	@Column(name="creater_id")
	private String createrId;// 商家添加用户
	
	private Date createDate;//商家添加时间
	
	private String logoUrl;//商家主LOGO
	
	private String businessTime;//营业时间
	
	private String reserveTime;//预约时间
	
	private String reserveTel;//预约电话
	
	private String busLine;//乘车路线
	
	private String description;//简介
	
	/**
	 * 所属同城
	 */
	private String areaNode;
	
	private String areaName;
	
	private String points;
	
	private String prop1;
	
	private String prop2;
	
	private String prop3;
	
	private String isDelete;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCounty() {
		return county;
	}

	public void setCounty(String county) {
		this.county = county;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getStar() {
		return star;
	}

	public void setStar(String star) {
		this.star = star;
	}

	public String getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public String getIsSend() {
		return isSend;
	}

	public void setIsSend(String isSend) {
		this.isSend = isSend;
	}

	public User getLegal() {
		return legal;
	}

	public void setLegal(User legal) {
		this.legal = legal;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Organization getParent() {
		return parent;
	}

	public void setParent(Organization parent) {
		this.parent = parent;
	}

	public double getSscore() {
		return sscore;
	}

	public void setSscore(double sscore) {
		this.sscore = sscore;
	}

	public double getAscore() {
		return ascore;
	}

	public void setAscore(double ascore) {
		this.ascore = ascore;
	}
	
	public String getCreaterId() {
		return createrId;
	}

	public void setCreaterId(String createrId) {
		this.createrId = createrId;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(String isDelete) {
		this.isDelete = isDelete;
	}

	public String getLogoUrl() {
		return logoUrl;
	}

	public void setLogoUrl(String logoUrl) {
		this.logoUrl = logoUrl;
	}

	public String getBusinessTime() {
		return businessTime;
	}

	public void setBusinessTime(String businessTime) {
		this.businessTime = businessTime;
	}

	public String getReserveTime() {
		return reserveTime;
	}

	public void setReserveTime(String reserveTime) {
		this.reserveTime = reserveTime;
	}

	public String getReserveTel() {
		return reserveTel;
	}

	public void setReserveTel(String reserveTel) {
		this.reserveTel = reserveTel;
	}

	public String getBusLine() {
		return busLine;
	}

	public void setBusLine(String busLine) {
		this.busLine = busLine;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getAreaNode() {
		return areaNode;
	}

	public void setAreaNode(String areaNode) {
		this.areaNode = areaNode;
	}

	public String getProp1() {
		return prop1;
	}

	public void setProp1(String prop1) {
		this.prop1 = prop1;
	}

	public String getProp2() {
		return prop2;
	}

	public void setProp2(String prop2) {
		this.prop2 = prop2;
	}

	public String getProp3() {
		return prop3;
	}

	public void setProp3(String prop3) {
		this.prop3 = prop3;
	}
	
	public String getPoints() {
		return points;
	}

	public void setPoints(String points) {
		this.points = points;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("code", this.getCode());
		obj.put("name", this.getName());
		obj.put("legal", this.getLegal() == null ?"":this.getLegal().getTruename());
		obj.put("tel", this.getTel());
		obj.put("ascore", this.getAscore());
		obj.put("sscore", this.getSscore());
		obj.put("areaNode", this.getAreaNode());
		obj.put("areaName", this.getAreaName());
		obj.put("type", this.getType());
		obj.put("address", this.getProvince()+this.getCity()+this.getCounty()+this.getAddress());
		return obj.toString();
	}

}
